home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / tasks.jar / content / tasks / tasksOverlay.js < prev    next >
Encoding:
Text File  |  2004-02-10  |  1.3 KB  |  59 lines

  1. function getAppFile(aPrefName)
  2. {
  3.   try 
  4.   {
  5.     var prefs = Components.classes["@mozilla.org/preferences-service;1"];
  6.     prefs = prefs.getService(Components.interfaces.nsIPrefBranch); 
  7.     var appFile = prefs.getComplexValue(aPrefName, Components.interfaces.nsILocalFile); 
  8.     return appFile
  9.   }
  10.   catch (ex) 
  11.   {
  12.     return null;
  13.   }
  14. }
  15.  
  16. function openApp(aPrefName) 
  17. {
  18.   var appFile = getAppFile(aPrefName);
  19.   if (appFile) 
  20.   {
  21.     try {
  22.       // this should cause the operating system to simulate double clicking 
  23.       // on the location which should launch your calendar application.
  24.       appFile.launch();
  25.     }
  26.     catch (ex)
  27.     { 
  28.     }
  29.   }
  30. }
  31.  
  32. function haveInternalCalendar()
  33. {
  34.   return ("@mozilla.org/ical-container;1" in Components.classes);
  35. }
  36.  
  37. function openOtherCal()
  38.   if (!haveInternalCalendar())
  39.     openApp("task.calendar.location");
  40. }
  41.  
  42. function OtherTasksOnLoad()
  43. {
  44.   var otherCalTaskBarIcon = document.getElementById("mini-other-cal");
  45.   var otherCalMenuItem = document.getElementById("tasksMenuOtherCal");
  46.  
  47.   var appFile = getAppFile("task.calendar.location");
  48.   if (appFile && !haveInternalCalendar())
  49.   {
  50.     if (otherCalTaskBarIcon)
  51.       otherCalTaskBarIcon.hidden = false;
  52.     if (otherCalMenuItem)
  53.       otherCalMenuItem.hidden = false;
  54.   }
  55. }
  56.  
  57. addEventListener("load", OtherTasksOnLoad, false);
  58.